package cn.skyquant.quant4j.service.boot.model.sms;

import cn.skyquant.quant4j.api.enums.SMSType;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface SmsCodeRepository extends CrudRepository<SmsCode, Integer> {
    @Query("select a from SmsCode a where tel = ?1 and type = ?2 and expireTime > ?3")
    List<SmsCode> findByTelTypeExpireTime(String tel, SMSType type, Date currentType);

    @Query("select count(*) from SmsCode a where tel = ?1 and type = ?2 and expireTime > ?3")
    int countByTelTypeExpireTime(String tel, SMSType type,Date currentType);
}
